/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: javase - Arr3
 * <p>Powered by webrx On 2021-11-26 14:24:05
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr3 {
    public static void main(String[] args) {
        var n = new Integer[]{1, 2, 50, 6, 99, 3};
        System.out.println(Arrays.toString(n));
        //Arrays.sort(n);
        //System.out.println(Arrays.binarySearch(n, 150));
        var rand = new Random();
        //js =>  java ->
        //Arrays.sort(n, (a, b) -> rand.nextBoolean() ? 1 : -1);
        //System.out.println(Arrays.toString(n));

        int index = 0;
        while (true) {
            int a = rand.nextInt(n.length);
            int b = rand.nextInt(n.length);
            if (a == b) continue;
            int t = n[a];
            n[a] = n[b];
            n[b] = t;
            if (++index >= 100000) break;
        }

        System.out.println(Arrays.toString(n));
    }
}
